function dtlist = TSdatelist(startdate, enddate)
% dtlist = TSdatelist(startdate, enddate)  Generate a TS structure datelist
% from startdate to enddate.  If startdate is not a scalar use its first
% and last elements for startdate and enddate
%
% Usage:
%    dtlist = TSdatelist(startdate, enddate)
%    dtlist = TSdatelist([startdate enddate])
%
% TODO: add functionality for daily format YYYYMMDD 
%

if nargin == 1
    startdt = startdate(1);
    enddt = startdate(end);
elseif length(startdate)>1
    startdt = startdate(1);
    enddt = startdate(end);
else
    startdt = startdate;
    enddt = enddate;
end

% convert start and end dates to 12*YYYY + MM, then generate a series of
% dates and convert back to YYYY*100 + MM
monthrange = floor([startdt enddt] / 100) * (12 - 100) + [startdt enddt] - 1;
monthlist  = (monthrange(1) : monthrange(2))';
dtlist     = floor(monthlist / 12) * (100 - 12) + monthlist + 1;

return